﻿<%@ Page Title="Rediger kunde" Language="C#" MasterPageFile="~/TsSite.Master" AutoEventWireup="true" CodeBehind="EditCustomer.aspx.cs" Inherits="TireService.Web.View.CustomerView.EditCustomer" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxClasses" tagprefix="dxw" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script src="../../Scripts/ModalPopup.js" type="text/javascript"></script>

    <table cellpadding="0" cellspacing="2" border="0">
        <tr>
            <td>
                <img id="imgCustomer" alt="" src="~/Images/Medium/businessmen.png" runat="server" style="width: 32px; height: 32px" />
            </td>
            <td valign="middle">
                <h3><asp:Label ID="lblCustomerHeader" runat="server" Text="Rediger kunde"></asp:Label></h3>
            </td>
            <td>
                <asp:UpdatePanel ID="upMessage" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <table border="0" cellspacing="0" cellpadding="5">
                            <tr>
                                <td>
                                    <div style="font-family: Tahoma; font-size: 9pt; font-weight: normal; color: #f15e34">
                                        &nbsp;<asp:Literal ID="lMessage" runat="server"></asp:Literal>
                                    </div>
                                </td>
                            </tr>
                        </table>          
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
    </table>                
    <hr />
    
    <script type="text/javascript">
    // <![CDATA[

        var MessageDetail;
        function OnMoreInfoClick(element, message) {
            MessageDetail = message;

            popup.Show();
        }

        // Show message
        function ShowMessage(values) {
            if (values == null) return;
            if (values.length == 0) return;
            MessageDetail = values[0];
            popup.Show();
        }

        function popup_Shown(s, e) {
            litText.SetText(MessageDetail);
        }
    // ]]> 
    </script>
    
    <dx:ASPxPopupControl ID="popup" ClientInstanceName="popup" runat="server" AllowDragging="true" AutoUpdatePosition="true"
        PopupHorizontalAlign="Center" PopupVerticalAlign="Middle" HeaderText="Besked" Width="400px">
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
                <table>
                    <tr>
                        <td>
                            <dxe:ASPxMemo ID="litText" ClientInstanceName="litText" runat="server" Height="400px" Width="400px">
                            </dxe:ASPxMemo>
                        </td>
                    </tr>
                </table>
            </dx:PopupControlContentControl>
        </ContentCollection>
        <ClientSideEvents Shown="popup_Shown" />
    </dx:ASPxPopupControl>
                    
    <asp:UpdatePanel ID="upActionControls" runat="server">
        <ContentTemplate>            
            <table border="0" cellspacing="0" cellpadding="5" width="100%">
                <tr>
                    <td>
                        <asp:DropDownList ID="ddlAction" runat="server">
                            <asp:ListItem Selected="True" Value="0">-- Handling --</asp:ListItem>
                            <asp:ListItem Value="1">Opret bruger og send email</asp:ListItem>
                            <asp:ListItem Value="2">Opret bruger</asp:ListItem>
                            <asp:ListItem Value="3">Send login detaljer til bruger</asp:ListItem>
                        </asp:DropDownList>
                        &nbsp;
                        <asp:Button ID="btnSubmitAction" runat="server" onclick="btnSubmitAction_Click" Text="Udfør" />
                        &nbsp;
                        <asp:Button ID="btnNewCustomer" runat="server" Text="Ny kunde" onclick="btnNewCustomer_Click" />
                    </td>
                    <td align="right">
                        <asp:LinkButton ID="lbtnPreviousCustomer" runat="server" Visible="false" 
                            onclick="lbtnPreviousCustomer_Click">Forrige</asp:LinkButton>&nbsp; 
                        <asp:LinkButton ID="lbtnNextCustomer" runat="server" Visible="false" 
                            onclick="lbtnNextCustomer_Click">Næste</asp:LinkButton>
                        <asp:Label ID="lblMultiEdit" runat="server" Text="" Visible="false"></asp:Label>&nbsp;
                    </td>
                </tr>
            </table>          
        </ContentTemplate>
    </asp:UpdatePanel>

    <!-- Javascript -->
    <script type="text/javascript">      
                
                
    </script>

    <asp:UpdatePanel ID="upEditCustomer" runat="server">
        <ContentTemplate>
            
            <!-- UI for edit customer contact data -->    
            <table border="0" cellspacing="0" cellpadding="5" width="100%">
                <tr>
                    <td>
                        <asp:Label ID="lblCustomerNumber" runat="server" Text="Kundenr:"></asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="lblCustomerNumberValue" runat="server" Text=""></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblParentCompany" runat="server" Text="Tilknyttet firma:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxComboBox ID="ddlParentCompany" DropDownStyle="DropDownList" IncrementalFilteringMode="StartsWith" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlParentCompany_SelectedIndexChanged">
                        </dxe:ASPxComboBox>
                    </td>
                </tr>
                <asp:Panel ID="pParentCompany" runat="server" Visible="false">
                    <tr>
                        <td>
                            <asp:Label ID="lblParentPayInvoice" runat="server" Text="Fakturer tilknyttet firma:"></asp:Label>
                        </td>
                        <td>
                            <dxe:ASPxCheckBox ID="cbParentPayInvoice" runat="server">
                            </dxe:ASPxCheckBox>
                        </td>
                    </tr>
                </asp:Panel>
                <tr>
                    <td>
                        <asp:Label ID="lblIsCompany" runat="server" Text="Firma:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxCheckBox ID="cbIsCompany" runat="server" AutoPostBack="true" OnValueChanged="cbIsCompany_CheckedChanged">
                        </dxe:ASPxCheckBox>
                    </td>
                </tr>
                <asp:Panel ID="pIsCompany" runat="server" Visible="false">
                    <tr>
                        <td>
                            <asp:Label ID="lblCompanyName" runat="server" Text="Firmanavn:"></asp:Label>
                        </td>
                        <td>
                            <dxe:ASPxTextBox ID="txtCompanyName" runat="server" Width="182px">
                            </dxe:ASPxTextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblCompanyNumber" runat="server" Text="CVR:"></asp:Label>
                        </td>
                        <td>
                            <dxe:ASPxTextBox ID="txtCompanyNumber" runat="server" Width="75px">
                            </dxe:ASPxTextBox>
                        </td>
                    </tr>
                </asp:Panel>
                <tr>
                    <td>
                        <asp:Label ID="lblName" runat="server" Text="Navn:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxTextBox ID="txtName" runat="server" Width="182px">
                        </dxe:ASPxTextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblAddress" runat="server" Text="Adresse:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxTextBox ID="txtAddress" runat="server" Width="182px">
                        </dxe:ASPxTextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblZipCode" runat="server" Text="Postnr:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxTextBox ID="txtZipCode" runat="server" Width="50px">
                            <MaskSettings Mask="0000" ErrorText="Postnr skal angives med 4 tal" />
                            <ValidationSettings ErrorDisplayMode="ImageWithTooltip" />
                        </dxe:ASPxTextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblCity" runat="server" Text="By:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxTextBox ID="txtCity" runat="server" Width="182px">
                        </dxe:ASPxTextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblCountry" runat="server" Text="Land:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxComboBox ID="ddlCountry" DropDownStyle="DropDownList" IncrementalFilteringMode="StartsWith" runat="server">
                        </dxe:ASPxComboBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblSecondaryAddress" runat="server" Text="Sekundær adresse:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxTextBox ID="txtSecondaryAddress" runat="server" Width="182px">
                        </dxe:ASPxTextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblSecondaryZipCode" runat="server" Text="Sekundær postnr:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxTextBox ID="txtSecondaryZipCode" runat="server" Width="50px">
                            <MaskSettings Mask="0000" ErrorText="Postnr skal angives med 4 tal" />
                            <ValidationSettings RequiredField-IsRequired="false" ErrorDisplayMode="ImageWithTooltip" />
                        </dxe:ASPxTextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblSecondaryCity" runat="server" Text="Sekundær by:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxTextBox ID="txtSecondaryCity" runat="server" Width="182px">
                        </dxe:ASPxTextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblPhone1" runat="server" Text="Telefon:"></asp:Label>
                    </td>
                    <td>
                        <table border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td>
                                    <dxe:ASPxTextBox ID="txtPhone1" runat="server" Width="75px">
                                        <MaskSettings Mask="00000000" ErrorText="Telefon nr. ikke gyldigt" />
                                        <ValidationSettings ErrorDisplayMode="ImageWithTooltip" />
                                    </dxe:ASPxTextBox>
                                </td>
                                <td>&nbsp;</td>
                                <td>
                                    <dxe:ASPxComboBox ID="ddlPhone1Type" runat="server" Width="75px">
                                        <Items>
                                            <dxe:ListEditItem Value="0" Text="Mobil" />
                                            <dxe:ListEditItem Value="1" Text="Fastnet" />
                                        </Items>
                                    </dxe:ASPxComboBox>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblPhone2" runat="server" Text="Telefon2:"></asp:Label>
                    </td>
                    <td>
                        <table border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td>
                                    <dxe:ASPxTextBox ID="txtPhone2" runat="server" Width="75">
                                        <MaskSettings Mask="00000000" ErrorText="Telefon nr. ikke gyldigt" />
                                        <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-IsRequired="false" />
                                    </dxe:ASPxTextBox>
                                </td>
                                <td>&nbsp;</td>
                                <td>
                                    <dxe:ASPxComboBox ID="ddlPhone2Type" runat="server" Width="75px">
                                        <Items>
                                            <dxe:ListEditItem Value="0" Text="Mobil" />
                                            <dxe:ListEditItem Value="1" Text="Fastnet" />
                                        </Items>
                                    </dxe:ASPxComboBox>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblEmail" runat="server" Text="Email:"></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxTextBox ID="txtEmail" runat="server" Width="182px">
                        </dxe:ASPxTextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblPrimaryAddressTimeInterval" runat="server" Text="I tidsrummet 8-16 holder bilen typisk på "></asp:Label>
                    </td>
                    <td>
                        <dxe:ASPxRadioButtonList ID="rbPrimaryAddressTimeInterval" runat="server" Width="250px">
                            <Items>
                                <dxe:ListEditItem Value="0" Text="Primær adressen" />
                                <dxe:ListEditItem Value="1" Text="Sekundær adressen" />
                            </Items>
                        </dxe:ASPxRadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td>
                        
                    </td>
                    <td>
                        <dxe:ASPxCheckBox ID="cbEconomicSync" Checked="true" runat="server" Text="Synkroniser med E-conomic">
                        </dxe:ASPxCheckBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <dxe:ASPxButton ID="btnSaveCustomer" runat="server" Text="Gem" OnClick="btnSaveCustomer_Click">
                        </dxe:ASPxButton>
                        <%--<asp:Button ID="btnSaveCustomer" runat="server" Text="Gem" 
                            OnClick="btnSaveCustomer_Click" />--%>
                        &nbsp;
                        <dxe:ASPxButton ID="btnSaveCustomerClose" runat="server" Text="Gem og afslut" OnClick="btnSaveCustomerClose_Click">
                        </dxe:ASPxButton>
                        <%--<asp:Button ID="btnSaveCustomerClose" runat="server" Text="Gem og afslut" 
                            OnClick="btnSaveCustomerClose_Click" />--%>
                    </td>
                </tr>
            </table>
            <hr />
            <!-- Subscription actions -->
            <table>
                <tr>
                    <td>
                        <dxe:ASPxComboBox ID="ddlSubscriptionAction" ClientInstanceName="ddlSubscriptionAction" runat="server">
                            <Items>
                                <dxe:ListEditItem Value="0" Selected="true" Text="-- Vælg handling --" />
                                <dxe:ListEditItem Value="1" Text="Deaktiver valgt" />
                            </Items>
                        </dxe:ASPxComboBox>
                    </td>
                    <td>
                        <dxe:ASPxButton ID="btnSubscriptionActions" runat="server" Text="Udfør" AutoPostBack="False" UseSubmitBehavior="False">
                            <ClientSideEvents Click="function(s, e) { SubscriptionActionClicked(); }" />
                        </dxe:ASPxButton>
                    </td>
                </tr>
            </table>
            <!-- Javascript for Subscription Actions Dropdownlist -->
            <script language="javascript" type="text/javascript">
                
                // Function that handles actions selected in subscription action dropdown list
                function SubscriptionActionClicked() {

                    // Get selected action from dropdownlist
                    var id = ddlSubscriptionAction.GetValue();

                    if (id != null && id != 0) {

                        // Deactivate subscription
                        if (id == 1) {
                            if (gvCustomerSubscription.GetFocusedRowIndex() == null) return;

                            // Get customersubscriptionid
                            gvCustomerSubscription.GetRowValues(gvCustomerSubscription.GetFocusedRowIndex(), 'CustomerSubscriptionId;InActive', RedirectToDeactivateForm);
                        }
                    }
                    else 
                    {
                        alert('Ingen handling valgt');
                    }
                }

                function RedirectToDeactivateForm(values) {
                    if (values == null) return;
                    if (values.length == 0) return;
//                    if (values[1] == true) {
//                        alert('Valgt abonnement er allerede deaktiveret');
//                    } else {
                        window.open('../AdminView/DeactivateSubscription.aspx?CustomerSubscriptionId=' + values[0]);
//                    }
                }

            </script>

            <!-- List with customer subscriptions -->
            <a name="subscription"></a>
            <dxwgv:ASPxGridView ID="gvCustomerSubscription" runat="server" 
                ClientInstanceName="gvCustomerSubscription" Caption="Abonnementer" 
                KeyFieldName="CustomerSubscriptionId" AutoGenerateColumns="False" Width="100%"  
                OnRowInserting="gvCustomerSubscription_RowInserting"
                OnRowUpdating="gvCustomerSubscription_RowUpdating" >
                <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                <SettingsPager AlwaysShowPager="false" PageSize="10" Position="Bottom">
                    <Summary 
                        AllPagesText="Sider: {0} - {1} ({2} abonnementer)" 
                        Text="Side {0} af {1} ({2} abonnementer)" />
                </SettingsPager>
                <SettingsText ConfirmDelete="Vil du slette dette abonnement?" />
                <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" ProcessFocusedRowChangedOnServer="false" AllowFocusedRow="true" />
                <Columns>
                    <dxwgv:GridViewCommandColumn VisibleIndex="0">
                        <EditButton Visible="True" Text="Rediger" />
                        <NewButton Visible="True" Text="Opret" />
                    </dxwgv:GridViewCommandColumn>
                    <dxwgv:GridViewDataHyperLinkColumn FieldName="CustomerSubscriptionId" VisibleIndex="3" Caption="Log">
                        <EditFormSettings Visible="False" />
                        <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/Popup/SubscriptionLogList.aspx?CustomerSubscriptionId={0}" TextField="CustomerSubscriptionId" Target="_blank">
                        </PropertiesHyperLinkEdit>
                    </dxwgv:GridViewDataHyperLinkColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="SubscriptionDropdown" FieldName="SubscriptionId" Caption="Abonnementtype" VisibleIndex="4">
                        <EditFormSettings VisibleIndex="0" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataColumn FieldName="StandardPrice" VisibleIndex="6" UnboundType="String" Caption="Standard pris">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="StandardCurrency" VisibleIndex="7" UnboundType="String" Caption="Valuta">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="Price" VisibleIndex="8" Caption="Kundens pris">
                        <EditFormSettings VisibleIndex="1" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="Createdate" VisibleIndex="12" Caption="Oprettelsesdato">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="LastRenewalDate" VisibleIndex="13" Caption="Sidst fornyet">
                        <EditFormSettings VisibleIndex="3" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="NextRenewalDate" VisibleIndex="14" Caption="Næste fornyelse">
                        <EditFormSettings VisibleIndex="4" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="BalancingIncluded" VisibleIndex="15" Caption="Afbalancering">
                        <EditFormSettings VisibleIndex="5" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="InActive" VisibleIndex="15" Caption="Deaktiveret">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="InActiveDate" VisibleIndex="16" Caption="Deaktiveringsdato">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataColumn>
                </Columns>
                <SettingsEditing PopupEditFormModal="false" PopupEditFormHorizontalAlign="Center" PopupEditFormAllowResize="false" Mode="PopupEditForm" PopupEditFormWidth="600px" />
                <Templates>
                    <EditForm>
                        <div style="text-align: right; padding: 2px">
                            <h4>Abonnement</h4>
                        </div>
                        <dxwgv:ASPxGridViewTemplateReplacement ID="Editors" ReplacementType="EditFormEditors" runat="server">
                        </dxwgv:ASPxGridViewTemplateReplacement>
                        <div style="text-align: left; padding: 2px">
                            <% if (gvCustomerSubscription.IsNewRowEditing)
                               { %>
                            <dxe:ASPxCheckBox ID="cbGenerateInvoice" runat="server" Text="Opret faktura">
                            </dxe:ASPxCheckBox>
                            <dxe:ASPxCheckBox ID="cbEmailInvoice" runat="server" Text="Send email med faktura">
                            </dxe:ASPxCheckBox>
                            <% } %>
                        </div>
                        <div style="text-align: right; padding: 2px">
                            <dxwgv:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton" runat="server">
                            </dxwgv:ASPxGridViewTemplateReplacement>
                            <dxwgv:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton" runat="server">
                            </dxwgv:ASPxGridViewTemplateReplacement>
                        </div>
                    </EditForm>
                </Templates>              
            </dxwgv:ASPxGridView>
            <hr />
            <!-- Subscription actions -->
            <table>
                <tr>
                    <td>
                        <dxe:ASPxComboBox ID="ddlCarAction" ClientInstanceName="ddlCarAction" runat="server">
                            <Items>
                                <dxe:ListEditItem Value="0" Selected="true" Text="-- Vælg handling --" />
                                <dxe:ListEditItem Value="1" Text="Book hjulskift for valgt bil(er)" />
                            </Items>
                        </dxe:ASPxComboBox>
                    </td>
                    <td>
                        <dxe:ASPxButton ID="btnCarAction" runat="server" Text="Udfør" AutoPostBack="False" UseSubmitBehavior="False">
                            <ClientSideEvents Click="function(s, e) { CarActionClicked(); }" />
                        </dxe:ASPxButton>
                    </td>
                </tr>
            </table>
            <!-- Javascript for Car Actions Dropdownlist -->
            <script language="javascript" type="text/javascript">

                // Function that handles actions selected in car action dropdown list
                function CarActionClicked() {

                    // Get selected action from dropdownlist
                    var id = ddlCarAction.GetValue();

                    if (id != null && id != 0) {

                        // Plan service for selected cars
                        if (id == 1) {
                            alert('Ikke implementeret endnu');
                        }
                    }
                    else {
                        alert('Ingen handling valgt');
                    }
                }

            </script>

            <!-- List with customer cars -->
            <a name="car"></a>
            <dxwgv:ASPxGridView ID="gvCar" runat="server" ClientInstanceName="gvCar" Width="100%" Caption="Biler"
                KeyFieldName="CarId" AutoGenerateColumns="False" EnableCallBacks="True"
                OnRowInserting="gvCar_RowInserting"
                OnRowUpdating="gvCar_RowUpdating" >
                <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                <SettingsPager AlwaysShowPager="false" PageSize="10" Position="Bottom">
                    <Summary 
                        AllPagesText="Sider: {0} - {1} ({2} biler)" 
                        Text="Side {0} af {1} ({2} biler)" />
                </SettingsPager>
                <SettingsText ConfirmDelete="Vil du slette denne bil?" />
                <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
                <Columns>
                    <dxwgv:GridViewCommandColumn VisibleIndex="0">
                        <EditButton Visible="True" Text="Rediger" />
                        <NewButton Visible="True" Text="Opret" />
                    </dxwgv:GridViewCommandColumn>
                    <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="1">
                            <HeaderTemplate>
                                <input type="checkbox" onclick="gvCar.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                            </HeaderTemplate>
                            <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                HorizontalAlign="Center">
                            <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                            </HeaderStyle>
                    </dxwgv:GridViewCommandColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="CustomerSubscriptionDropdown" FieldName="CustomerSubscriptionId" Caption="Abonnement" VisibleIndex="3">
                        <EditFormSettings VisibleIndex="0" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="4" Caption="Reg.nr.">
                        <EditFormSettings VisibleIndex="1" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="CarBrandDropdown" FieldName="CarBrandId" Caption="Bilmærke" VisibleIndex="5">
                        <EditFormSettings VisibleIndex="2" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataColumn FieldName="Model" VisibleIndex="6" Caption="Model">
                        <EditFormSettings VisibleIndex="3" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="EngineSize" VisibleIndex="7" Caption="Motor" Visible="false">
                        <EditFormSettings VisibleIndex="4" Visible="True" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="FuelTypeDropdown" FieldName="FuelType" Caption="Brændstof" VisibleIndex="8">
                        <EditFormSettings VisibleIndex="5" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataColumn FieldName="Year" VisibleIndex="9" Caption="Årgang">
                        <EditFormSettings VisibleIndex="6" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="Color" VisibleIndex="10" Caption="Farve" Visible="false">
                        <EditFormSettings VisibleIndex="7" Visible="True" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="CarStatusDropdown" FieldName="CarStatusId" Caption="Status" VisibleIndex="11">
                        <EditFormSettings VisibleIndex="8" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataColumn FieldName="Createdate" VisibleIndex="12" Caption="Oprettelsesdato">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="LastTireSetChangeDate" VisibleIndex="13" Caption="Sidst dækskift">
                        <EditFormSettings VisibleIndex="9" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="NextTireSetChangePlanningDate" VisibleIndex="14" Caption="Næste planlægningsdato">
                        <EditFormSettings VisibleIndex="10" />
                    </dxwgv:GridViewDataColumn>
                </Columns>  
                <SettingsEditing PopupEditFormModal="false" PopupEditFormHorizontalAlign="Center" PopupEditFormAllowResize="false" Mode="PopupEditForm" PopupEditFormWidth="600px" />
                <Templates>
                    <EditForm>
                        <div style="text-align: left; padding: 2px">
                            <h4>Bil</h4>
                        </div>
                        <dxwgv:ASPxGridViewTemplateReplacement ID="Editors" ReplacementType="EditFormEditors" runat="server">
                        </dxwgv:ASPxGridViewTemplateReplacement>
                        <div style="text-align: left; padding: 2px">
                            <% if(gvCar.IsNewRowEditing) { %>
                                Nuværende hjul på bilen:
                                <dxe:ASPxRadioButtonList ID="rblCurrentTireSet" runat="server" Width="250px">
                                    <Items>
                                        <dxe:ListEditItem Value="0" Text="Vinterhjul" Selected="true" />
                                        <dxe:ListEditItem Value="1" Text="Sommerhjul" />
                                    </Items>
                                </dxe:ASPxRadioButtonList>
                            <% } %>
                        </div>
                        <div style="text-align: right; padding: 2px">
                            <dxwgv:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton" runat="server">
                            </dxwgv:ASPxGridViewTemplateReplacement>
                            <dxwgv:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton" runat="server">
                            </dxwgv:ASPxGridViewTemplateReplacement>
                        </div>
                    </EditForm>
                </Templates>                                          
            </dxwgv:ASPxGridView>
            <asp:Button ID="btnCreateServiceBooking" runat="server" 
                Text="Book hjulskift for valgt bil(er)" 
                onclick="btnCreateServiceBooking_Click" />
            <hr />
            <!-- TireSet actions -->
            <table>
                <tr>
                    <td>
                        <dxe:ASPxComboBox ID="ddlTireSetAction" ClientInstanceName="ddlTireSetAction" runat="server">
                            <Items>
                                <dxe:ListEditItem Value="0" Selected="true" Text="-- Vælg handling --" />
                                <dxe:ListEditItem Value="1" Text="Opret nye dæk - kasser gamle/valgte" />
                                <dxe:ListEditItem Value="2" Text="Opret nye dæk - erstat dummy" />
                            </Items>
                        </dxe:ASPxComboBox>
                    </td>
                    <td>
                        <dxe:ASPxButton ID="btnTireSetAction" runat="server" Text="Udfør" AutoPostBack="False" UseSubmitBehavior="False">
                            <ClientSideEvents Click="function(s, e) { TireSetActionClicked(); }" />
                        </dxe:ASPxButton>
                    </td>
                </tr>
            </table>
            <!-- Javascript for Subscription Actions Dropdownlist -->
            <script language="javascript" type="text/javascript">

                // Function that handles actions selected in tireset action dropdown list
                function TireSetActionClicked() {

                    // Get selected action from dropdownlist
                    var id = ddlTireSetAction.GetValue();

                    if (id != null && id != 0) {

                        // Deactivate subscription
                        if (id == 1) {
                            if (gvTireSet.GetFocusedRowIndex() == null) return;

                            // Get TireSetId and DummyTireSet
                            gvTireSet.GetRowValues(gvTireSet.GetFocusedRowIndex(), 'TireSetId;DummyTireSet', RedirectNewTireSetDeactivate);
                        }
                        if (id == 2) {
                            if (gvTireSet.GetFocusedRowIndex() == null) return;
                        }
                    }
                    else {
                        alert('Ingen handling valgt');
                    }
                }

                function RedirectNewTireSetDeactivate(values) {
                    if (values == null) return;
                    if (values.length == 0) return;
                    if (values[1] == true) {
                        alert('Valgt hjulsæt er et dummy hjul, dette kan ikke deaktiveres. Venligst vælg: Opret nye dæk - erstat dummy');
                    } else {
                        window.open('../AdminView/TireSetPurchase.aspx?Action=Deactivate&TireSetId=' + values[0]);
                    }
                }

                function RedirectNewTireSetReplace(values) {
                    if (values == null) return;
                    if (values.length == 0) return;
                    if (values[1] == false) {
                        alert('Valgt hjulsæt er IKKE et dummy hjul, dette kan ikke erstattes. Venligst vælg: Opret nye dæk - kasser gamle/valgte');
                    } else {
                        window.open('../AdminView/TireSetPurchase.aspx?Action=Replace&TireSetId=' + values[0]);
                    }
                }

            </script>

            <!-- List with customer tireset -->
            <a name="tireset"></a>
            <dxwgv:ASPxGridView ID="gvTireSet" runat="server" ClientInstanceName="gvTireSet" Width="100%" Caption="Hjulsæt"
                KeyFieldName="TireSetId" AutoGenerateColumns="False" EnableCallBacks="True" 
                OnRowInserting="gvTireSet_RowInserting"
                OnRowUpdating="gvTireSet_RowUpdating">
                <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                <SettingsPager AlwaysShowPager="false" PageSize="10" Position="Bottom">
                    <Summary 
                        AllPagesText="Sider: {0} - {1} ({2} hjulsæt)" 
                        Text="Side {0} af {1} ({2} hjulsæt)" />
                </SettingsPager>
                <SettingsText ConfirmDelete="Vil du slette dette hjulsæt?" />
                <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" ProcessFocusedRowChangedOnServer="false" AllowFocusedRow="true" />
                <Columns>
                    <dxwgv:GridViewCommandColumn VisibleIndex="0">
                        <EditButton Visible="True" Text="Rediger" />
                        <NewButton Visible="True" Text="Opret" />
                    </dxwgv:GridViewCommandColumn>
                    <dxwgv:GridViewDataHyperLinkColumn FieldName="TireSetId" VisibleIndex="1" Caption="Log">
                        <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/Popup/TireSetLogList.aspx?TireSetId={0}" Text="Vis log" Target="_blank" >
                        </PropertiesHyperLinkEdit>
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataHyperLinkColumn>
                    <dxwgv:GridViewDataColumn FieldName="CarBrandDescription" VisibleIndex="2" Caption="Bilmærke">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="CarDropdown" FieldName="CarId" Caption="Bil" VisibleIndex="11" Visible="false">
                        <EditFormSettings VisibleIndex="1" Visible="True" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataColumn FieldName="Model" VisibleIndex="3" Caption="Model">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="TireSetId" VisibleIndex="4" Caption="Dæksæt ID">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="TireSetStatusDropdown" FieldName="TireSetStatusId" Caption="Status" VisibleIndex="5">
                        <EditFormSettings VisibleIndex="2" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="TireTypeDropdown" FieldName="TireTypeId" Caption="Dæktype" VisibleIndex="6">
                        <EditFormSettings VisibleIndex="3" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="TireBrandDropdown" FieldName="TireBrandId" Caption="Mærke" VisibleIndex="7">
                        <EditFormSettings VisibleIndex="4" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataColumn FieldName="TireBrandNote" VisibleIndex="8" Caption="Model variant">
                        <EditFormSettings VisibleIndex="5" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="WidthDropdown" FieldName="Width" Caption="Bredde" VisibleIndex="9">
                        <EditFormSettings VisibleIndex="6" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="HeightDropdown" FieldName="Height" Caption="Højde." VisibleIndex="10">
                        <EditFormSettings VisibleIndex="7" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="SizeDropdown" FieldName="Size" Caption="Fælgstr." VisibleIndex="11">
                        <EditFormSettings VisibleIndex="8" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="TireSpeedIndexDropdown" FieldName="TireSpeedIndexId" Caption="Hastighedsindex" VisibleIndex="11" Visible="false">
                        <EditFormSettings VisibleIndex="9" Visible="True" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="TireLoadIndexDropdown" FieldName="TireLoadIndexId" Caption="Belastningsindex" VisibleIndex="11" Visible="false">
                        <EditFormSettings VisibleIndex="10" Visible="True" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataColumn FieldName="LockingBolt" VisibleIndex="5" Caption="Låsebolte" Visible="false">
                        <EditFormSettings VisibleIndex="11" Visible="True" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="HubCaps" VisibleIndex="5" Caption="Hjulkapsler" Visible="false">
                        <EditFormSettings VisibleIndex="12" Visible="True" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="RunFlatTire" VisibleIndex="5" Caption="Runflat dæk" Visible="false">
                        <EditFormSettings VisibleIndex="13" Visible="True" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="RimProtection" VisibleIndex="5" Caption="Kantbeskytter" Visible="false">
                        <EditFormSettings VisibleIndex="14" Visible="True" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="ExtraBolts" VisibleIndex="5" Caption="Ekstra bolte" Visible="false">
                        <EditFormSettings VisibleIndex="15" Visible="True" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="SocketWrenchSize" VisibleIndex="5" Caption="Topnøgle str." Visible="false">
                        <EditFormSettings VisibleIndex="16" Visible="True" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="ManufactureDate" VisibleIndex="5" Caption="Prod. dato" Visible="false">
                        <EditFormSettings VisibleIndex="17" Visible="True" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="LastBalancingDate" VisibleIndex="13" Caption="Sidste afbal.">
                        <EditFormSettings VisibleIndex="18" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="NeedBalancing" VisibleIndex="12" Caption="Skal afbal.">
                        <EditFormSettings VisibleIndex="19" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataComboBoxColumn Name="DummyTireSet" FieldName="DummyTireSet" VisibleIndex="15" Visible="false">
                        <EditFormSettings VisibleIndex="20" Visible="false" />
                    </dxwgv:GridViewDataComboBoxColumn>
                    <dxwgv:GridViewDataColumn FieldName="TireSetId" VisibleIndex="4" Caption="Dæksæt ID">
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataHyperLinkColumn FieldName="ContainerCargoRoomId" VisibleIndex="14" Caption="Lager">
                        <PropertiesHyperLinkEdit NavigateUrlFormatString="~/Casehandling/EditContainer.aspx?ContainerCargoRoomId={0}" TextField="ContainerCargoRoomId" >
                        </PropertiesHyperLinkEdit>
                        <EditFormSettings Visible="False" />
                    </dxwgv:GridViewDataHyperLinkColumn>
                </Columns>                                            
                <SettingsEditing PopupEditFormModal="false" PopupEditFormHorizontalAlign="Center" PopupEditFormAllowResize="false" Mode="PopupEditForm" PopupEditFormWidth="600px" />
                <Templates>
                    <EditForm>
                        <div style="text-align: left; padding: 2px">
                            <h4>Hjulsæt</h4>
                        </div>
                        <dxwgv:ASPxGridViewTemplateReplacement ID="Editors" ReplacementType="EditFormEditors" runat="server">
                        </dxwgv:ASPxGridViewTemplateReplacement>
                        <% if(!gvTireSet.IsNewRowEditing) { %>
                            

                        <% } %>

                        <div style="text-align: right; padding: 2px">
                            <dxwgv:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton" runat="server">
                            </dxwgv:ASPxGridViewTemplateReplacement>
                            <dxwgv:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton" runat="server">
                            </dxwgv:ASPxGridViewTemplateReplacement>
                        </div>
                    </EditForm>
                </Templates>
            </dxwgv:ASPxGridView>
            <hr />
            <!-- List with customer invoices -->
            <a name="invoice"></a>
            <dxwgv:ASPxGridView ID="gvInvoice" runat="server" ClientInstanceName="gvInvoice" KeyFieldName="Number"
                Width="100%" AutoGenerateColumns="False" EnableCallBacks="True" Caption="Faktura">
                <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                <Settings ShowPreview="false" ShowHeaderFilterButton="false" ShowGroupPanel="false" ShowFilterRow="false" />
                <SettingsPager AlwaysShowPager="false" PageSize="10" Position="Bottom">
                    <Summary 
                        AllPagesText="Sider: {0} - {1} ({2} fakturaer)" 
                        Text="Side {0} af {1} ({2} fakturaer)" />
                </SettingsPager>
                <SettingsText ConfirmDelete="Vil du slette denne faktura?" GroupPanel="Træk kolonne hertil for at gruppere efter den" HeaderFilterShowAll="Vis alle" />
                <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
                <Columns>
                    <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                            <HeaderTemplate>
                                <input type="checkbox" onclick="gvInvoice.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                            </HeaderTemplate>
                            <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                HorizontalAlign="Center">
                            <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                            </HeaderStyle>
                    </dxwgv:GridViewCommandColumn>
                    <dxwgv:GridViewDataHyperLinkColumn FieldName="Number" VisibleIndex="3" Caption="Vis faktura">
                        <PropertiesHyperLinkEdit NavigateUrlFormatString="http://www.mobilhjulskift.dk/Reports/View/Faktura.aspx?InvoiceId={0}" Target="_blank" Text="Vis" >
                        </PropertiesHyperLinkEdit>
                    </dxwgv:GridViewDataHyperLinkColumn>
                    <dxwgv:GridViewDataColumn FieldName="Number" Visible="true" VisibleIndex="3" Caption="Nr">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataTextColumn FieldName="Date" VisibleIndex="3" Caption="Fakturadato">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn FieldName="DueDate" VisibleIndex="3" Caption="Forfaldsdato">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataColumn FieldName="GrossAmount" VisibleIndex="4" Caption="Beløb">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="Remainder" VisibleIndex="8" Caption="Udestående">
                    </dxwgv:GridViewDataColumn>
                </Columns>
                <Settings ShowFooter="True" />                     
                <TotalSummary>
                    <dxwgv:ASPxSummaryItem FieldName="GrossAmount" SummaryType="Sum" />
                    <dxwgv:ASPxSummaryItem FieldName="Remainder" SummaryType="Sum" />
                </TotalSummary>                
            </dxwgv:ASPxGridView>
            <hr />
            <!-- List with past and planned tirechanges -->
            <a name="tirechange"></a>
            <dxwgv:ASPxGridView ID="gvService" runat="server" ClientInstanceName="gvService" Width="100%" Caption="Hjulskift og servicekørsler"
                KeyFieldName="ServiceCarScheduleDetailId" AutoGenerateColumns="False" EnableCallBacks="False">
                <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                <Settings ShowHeaderFilterButton="false" ShowGroupPanel="false" ShowFilterRow="false" />
                <SettingsPager AlwaysShowPager="false" PageSize="10" Position="Bottom">
                    <Summary 
                        AllPagesText="Sider: {0} - {1} ({2} hjulskift)" 
                        Text="Side {0} af {1} ({2} hjulskift)" />
                </SettingsPager>
                <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
                <Columns>
                    <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                            <HeaderTemplate>
                                <input type="checkbox" onclick="gvService.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                            </HeaderTemplate>
                            <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                HorizontalAlign="Center">
                            <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                            </HeaderStyle>
                    </dxwgv:GridViewCommandColumn>

                    <dxwgv:GridViewDataHyperLinkColumn FieldName="CustomerId" VisibleIndex="5" Caption="Kontakt">
                        <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomer.aspx?CustomerId={0}" TextField="Name">
                        </PropertiesHyperLinkEdit>
                    </dxwgv:GridViewDataHyperLinkColumn>
                    <dxwgv:GridViewDataColumn FieldName="Name" VisibleIndex="5" Caption="Kontakt" Visible="false">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="ScheduleDate" VisibleIndex="6" Caption="Dato">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="6" Caption="Reg.nr.">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataTextColumn FieldName="CarBrandDescription" VisibleIndex="7" Caption="Bilmærke">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn FieldName="FromTireSetDescription" VisibleIndex="7" Caption="Fra">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn FieldName="ToTireSetDescription" VisibleIndex="7" Caption="Til">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataCheckColumn FieldName="CustomerConfirmed" VisibleIndex="13" Caption="Godkendt">
                    </dxwgv:GridViewDataCheckColumn>
                    <dxwgv:GridViewDataCheckColumn FieldName="WorkCompleted" VisibleIndex="13" Caption="Gennemført">
                    </dxwgv:GridViewDataCheckColumn>
                    <dxwgv:GridViewDataCheckColumn FieldName="CustomerRated" VisibleIndex="13" Caption="Anmeldt">
                    </dxwgv:GridViewDataCheckColumn>
                </Columns>                                            
            </dxwgv:ASPxGridView>
            <hr />
            <!-- List with subdepartmens for customer -->
            <a name="subdepartment"></a>
            <dxwgv:ASPxGridView ID="gvCustomer" runat="server" ClientInstanceName="gvCustomer" Caption="Underafdelinger/Kontakter" 
                KeyFieldName="CustomerId" Width="100%" AutoGenerateColumns="False" EnableCallBacks="False" 
                oncustomunboundcolumndata="gvCustomer_CustomUnboundColumnData" >
                <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                <Settings ShowHeaderFilterButton="false" ShowGroupPanel="false" ShowFilterRow="false" />
                <SettingsPager AlwaysShowPager="false" PageSize="10" Position="Bottom">
                    <Summary 
                        AllPagesText="Sider: {0} - {1} ({2} kunder)" 
                        Text="Side {0} af {1} ({2} kunder)" />
                </SettingsPager>
                <SettingsText ConfirmDelete="Vil du slette denne kunde?" GroupPanel="Træk kolonne hertil for at gruppere efter den" HeaderFilterShowAll="Vis alle" />
                <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
                            
                <Columns>
                    <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                            <HeaderTemplate>
                                <input type="checkbox" onclick="gvCustomer.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                            </HeaderTemplate>
                            <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                HorizontalAlign="Center">
                            <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                            </HeaderStyle>
                    </dxwgv:GridViewCommandColumn>
                    <dxwgv:GridViewDataHyperLinkColumn FieldName="CustomerId" VisibleIndex="0" Caption="Kundenr">
                        <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomer.aspx?CustomerId={0}" TextField="CustomerId">
                        </PropertiesHyperLinkEdit>
                    </dxwgv:GridViewDataHyperLinkColumn>
                    <dxwgv:GridViewDataHyperLinkColumn FieldName="ParentCustomerId" VisibleIndex="2" Caption="Afdeling">
                        <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomer.aspx?CustomerId={0}" TextField="ParentCompanyName">
                        </PropertiesHyperLinkEdit>
                    </dxwgv:GridViewDataHyperLinkColumn>
                    <dxwgv:GridViewDataColumn FieldName="CompanyName" VisibleIndex="3" Caption="Firma">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="Name" VisibleIndex="3" Caption="Navn">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="Address" VisibleIndex="4" Caption="Adresse">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="ZipCode" VisibleIndex="5" Caption="Postnr">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="City" VisibleIndex="6" Caption="By">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="CountryId" VisibleIndex="7" Caption="CountryId" Visible="false">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataTextColumn FieldName="CountryName" VisibleIndex="8" UnboundType="String" Caption="Land">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataColumn FieldName="Phone1" VisibleIndex="12" Caption="Telefon">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="Phone2" VisibleIndex="13" Caption="Telefon2">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="Email" VisibleIndex="14" Caption="Email">
                    </dxwgv:GridViewDataColumn>
                </Columns>
                            
            </dxwgv:ASPxGridView>
            <hr />
            <!-- List with maillog for customer -->
            <a name="maillog"></a>
            <dxwgv:ASPxGridView ID="gvCustomerEmailLog" runat="server" ClientInstanceName="gvCustomerEmailLog" Caption="Mail log" 
                KeyFieldName="ServiceCarScheduleDetailRatingId" 
                AutoGenerateColumns="False" EnableCallBacks="False" Width="100%"
                oncustombuttoncallback="gvCustomerEmailLog_CustomButtonCallback" >
                <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                <Settings ShowHeaderFilterButton="false" ShowGroupPanel="false" ShowFilterRow="false" />
                <SettingsPager AlwaysShowPager="false" PageSize="10" Position="Bottom">
                    <Summary 
                        AllPagesText="Sider: {0} - {1} ({2} emails)" 
                        Text="Side {0} af {1} ({2} emails)" />
                </SettingsPager>
                <SettingsText ConfirmDelete="Vil du slette denne anmeldelse?" />
                <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
                <Columns>
                    <dxwgv:GridViewDataHyperLinkColumn FieldName="CustomerId" VisibleIndex="0" Caption="Afdeling/Kontakt">
                        <PropertiesHyperLinkEdit NavigateUrlFormatString="~/View/CustomerView/EditCustomer.aspx?CustomerId={0}" TextField="CustomerId">
                        </PropertiesHyperLinkEdit>
                    </dxwgv:GridViewDataHyperLinkColumn>
                    <dxwgv:GridViewDataColumn FieldName="Name" VisibleIndex="1" Caption="Afdeling/Kontakt">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="SendDate" VisibleIndex="2" Caption="Dato">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="Subject" VisibleIndex="3" Caption="Emne">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="ToEmail" VisibleIndex="4" Caption="Sendt til">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn FieldName="FromEmail" VisibleIndex="4" Caption="Sendt fra">
                    </dxwgv:GridViewDataColumn>
                    <dxwgv:GridViewDataColumn VisibleIndex="4" Caption="Detaljer">
                        <DataItemTemplate>
                            <a href="javascript:void(0);" onclick="OnMoreInfoClick(this, '<%# Eval("Message") %>')">Vis besked...</a>
                        </DataItemTemplate>
                    </dxwgv:GridViewDataColumn>
                </Columns>                                            
            </dxwgv:ASPxGridView>
            <%--<br />
            <asp:Literal ID="lEmailMessage" runat="server" Visible="false"></asp:Literal>
            <br />
            <asp:Button ID="btnCloseMessage" runat="server" Text="Luk besked" Visible="false" 
                onclick="btnCloseMessage_Click" />--%>
            
        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
